#!/usr/bin/env /usr/local/python3
# -*- coding: utf-8 -*-

from urllib.parse import unquote
import json

"""
解析验证探针数据
"""

__author__ = "hubert"


file_path = "C:/data/git/doc_hubert/doc/004售前工作/探针/log/bigdata-spark-60.167.225.133-2021-05-13.log"
file = open(file_path, "rb")

for line in file:
    # 去掉换行符，得到数组
    str_txt = line.decode('utf-8').strip("\n")

    # 转换为list
    str_list = eval(str_txt)

    json_log0 = unquote(str_list[0], "utf-8").replace("/log?d=", "")
    # 将字符串转换为字典
    json_log_list = json.loads(json_log0)
    print(json_log_list)

    for key in json_log_list:
        if json_log_list[key] == "":
            print(key, ":值为空")
        else:
            print(key, ":", json_log_list[key])








